class Solution {
public:
    int halveArray(vector<int>& nums) {
        int ret = 0;
        double sum = 0, target = 0;
        priority_queue<double> q(nums.begin(), nums.end());
        for(auto& e : nums)
        {
            sum += e;
        }
        target = sum / 2;
        while(target < sum)
        {
            double tmp = q.top() / 2;
            q.pop();
            q.push(tmp);
            sum -= tmp;
            ++ret;
        }
        return ret;
    }
};